package com.dbh.alg.algorithm.recursion;

import cn.hutool.core.collection.ListUtil;
import com.dbh.alg.datastructure.queue.LinkedListQueue;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;


/**
 * @author dongbanghui
 * @date 2025/5/15
 */
public class OfflineLinkedListQueue {

    @Test
    public void offer() {
        LinkedListQueue<Integer> queue = new LinkedListQueue<>();
        queue.offer(1);
        queue.offer(2);
        queue.offer(3);
        queue.offer(4);
        queue.offer(5);

        Assertions.assertIterableEquals(ListUtil.of(1, 2, 3, 4, 5), queue);
    }

    @Test
    public void peek() {
        LinkedListQueue<Integer> queue = new LinkedListQueue<>();
        queue.offer(1);
        Assertions.assertEquals(1, queue.peek());
        queue.offer(2);
        Assertions.assertEquals(1, queue.peek());
    }

    @Test
    public void poll() {
        LinkedListQueue<Integer> queue = new LinkedListQueue<>();
        queue.offer(1);
        queue.offer(2);
        queue.offer(3);
        queue.offer(4);
        queue.offer(5);
        Assertions.assertEquals(1, queue.poll());
        Assertions.assertEquals(2, queue.poll());
        Assertions.assertEquals(3, queue.poll());
        Assertions.assertEquals(4, queue.poll());
        Assertions.assertEquals(5, queue.poll());

        Assertions.assertNull(queue.poll());

    }
}
